<?php

namespace SinoPHP\BbdBoss\Model;

use Upfor\UpforPHP\Model;

class ServerGroupRole extends Model {

    /**
     * 获取服务器角色
     * @param string $role_name
     * @param int $id
     * @return array
     */
    public function getRoleName($role_name = '',$id = null) {

        $sql = "SELECT * FROM `server_group_role` WHERE `role_name` = '{$role_name}' AND `server_role_id` != {$id} AND `is_delete` = 0";

        $data = $this->db->query($sql);

        return $data;
    }

    public function searchList($query = '',$limit = null, $offset = null) {

        $sql = "SELECT * FROM `server_group_role` WHERE `is_delete` = 0 ";

        if ($query) {
            $sql .= " AND `role_name` LIKE '%".$query."%'";
        }

        if ($limit) {
            $sql .= " LIMIT {$offset},{$limit}";
        }
        $data = $this->db->query($sql);

        return $data;
    }

}